package org.openwork.portlet.skillmanagement.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.util.PortalUtil;

import org.openwork.portlet.skillmanagement.model.SkillUser;
import org.openwork.portlet.skillmanagement.model.SkillUserSoap;
import org.openwork.portlet.skillmanagement.service.persistence.SkillUserPK;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * <a href="SkillUserModelImpl.java.html"><b><i>View Source</i></b></a>
 *
 * <p>
 * ServiceBuilder generated this class. Modifications in this class will be
 * overwritten the next time is generated.
 * </p>
 *
 * <p>
 * This interface is a model that represents the Skill_SkillUser table in the
 * database.
 * </p>
 *
 * @author    Samuel Garcia Martinez
 * @see       SkillUserImpl
 * @see       org.openwork.portlet.skillmanagement.model.SkillUser
 * @see       org.openwork.portlet.skillmanagement.model.SkillUserModel
 * @generated
 */
public class SkillUserModelImpl extends BaseModelImpl<SkillUser> {
    public static final String TABLE_NAME = "Skill_SkillUser";
    public static final Object[][] TABLE_COLUMNS = {
            { "userId", new Integer(Types.BIGINT) },
            { "skillId", new Integer(Types.BIGINT) },
            { "auditUserId", new Integer(Types.BIGINT) },
            { "createDate", new Integer(Types.TIMESTAMP) },
            { "modifiedDate", new Integer(Types.TIMESTAMP) },
            { "experience", new Integer(Types.INTEGER) }
        };
    public static final String TABLE_SQL_CREATE = "create table Skill_SkillUser (userId LONG not null,skillId LONG not null,auditUserId LONG,createDate DATE null,modifiedDate DATE null,experience INTEGER,primary key (userId, skillId))";
    public static final String TABLE_SQL_DROP = "drop table Skill_SkillUser";
    public static final String DATA_SOURCE = "liferayDataSource";
    public static final String SESSION_FACTORY = "liferaySessionFactory";
    public static final String TX_MANAGER = "liferayTransactionManager";
    public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.entity.cache.enabled.org.openwork.portlet.skillmanagement.model.SkillUser"),
            true);
    public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.finder.cache.enabled.org.openwork.portlet.skillmanagement.model.SkillUser"),
            true);
    public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
                "lock.expiration.time.org.openwork.portlet.skillmanagement.model.SkillUser"));
    private long _userId;
    private String _userUuid;
    private long _skillId;
    private long _auditUserId;
    private String _auditUserUuid;
    private Date _createDate;
    private Date _modifiedDate;
    private Short _experience;

    public SkillUserModelImpl() {
    }

    public static SkillUser toModel(SkillUserSoap soapModel) {
        SkillUser model = new SkillUserImpl();

        model.setUserId(soapModel.getUserId());
        model.setSkillId(soapModel.getSkillId());
        model.setAuditUserId(soapModel.getAuditUserId());
        model.setCreateDate(soapModel.getCreateDate());
        model.setModifiedDate(soapModel.getModifiedDate());
        model.setExperience(soapModel.getExperience());

        return model;
    }

    public static List<SkillUser> toModels(SkillUserSoap[] soapModels) {
        List<SkillUser> models = new ArrayList<SkillUser>(soapModels.length);

        for (SkillUserSoap soapModel : soapModels) {
            models.add(toModel(soapModel));
        }

        return models;
    }

    public SkillUserPK getPrimaryKey() {
        return new SkillUserPK(_userId, _skillId);
    }

    public void setPrimaryKey(SkillUserPK pk) {
        setUserId(pk.userId);
        setSkillId(pk.skillId);
    }

    public Serializable getPrimaryKeyObj() {
        return new SkillUserPK(_userId, _skillId);
    }

    public long getUserId() {
        return _userId;
    }

    public void setUserId(long userId) {
        _userId = userId;
    }

    public String getUserUuid() throws SystemException {
        return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
    }

    public void setUserUuid(String userUuid) {
        _userUuid = userUuid;
    }

    public long getSkillId() {
        return _skillId;
    }

    public void setSkillId(long skillId) {
        _skillId = skillId;
    }

    public long getAuditUserId() {
        return _auditUserId;
    }

    public void setAuditUserId(long auditUserId) {
        _auditUserId = auditUserId;
    }

    public String getAuditUserUuid() throws SystemException {
        return PortalUtil.getUserValue(getAuditUserId(), "uuid", _auditUserUuid);
    }

    public void setAuditUserUuid(String auditUserUuid) {
        _auditUserUuid = auditUserUuid;
    }

    public Date getCreateDate() {
        return _createDate;
    }

    public void setCreateDate(Date createDate) {
        _createDate = createDate;
    }

    public Date getModifiedDate() {
        return _modifiedDate;
    }

    public void setModifiedDate(Date modifiedDate) {
        _modifiedDate = modifiedDate;
    }

    public Short getExperience() {
        return _experience;
    }

    public void setExperience(Short experience) {
        _experience = experience;
    }

    public SkillUser toEscapedModel() {
        if (isEscapedModel()) {
            return (SkillUser) this;
        } else {
            return (SkillUser) Proxy.newProxyInstance(SkillUser.class.getClassLoader(),
                new Class[] { SkillUser.class }, new AutoEscapeBeanHandler(this));
        }
    }

    public Object clone() {
        SkillUserImpl clone = new SkillUserImpl();

        clone.setUserId(getUserId());
        clone.setSkillId(getSkillId());
        clone.setAuditUserId(getAuditUserId());
        clone.setCreateDate(getCreateDate());
        clone.setModifiedDate(getModifiedDate());
        clone.setExperience(getExperience());

        return clone;
    }

    public int compareTo(SkillUser skillUser) {
        SkillUserPK pk = skillUser.getPrimaryKey();

        return getPrimaryKey().compareTo(pk);
    }

    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }

        SkillUser skillUser = null;

        try {
            skillUser = (SkillUser) obj;
        } catch (ClassCastException cce) {
            return false;
        }

        SkillUserPK pk = skillUser.getPrimaryKey();

        if (getPrimaryKey().equals(pk)) {
            return true;
        } else {
            return false;
        }
    }

    public int hashCode() {
        return getPrimaryKey().hashCode();
    }

    public String toString() {
        StringBundler sb = new StringBundler(13);

        sb.append("{userId=");
        sb.append(getUserId());
        sb.append(", skillId=");
        sb.append(getSkillId());
        sb.append(", auditUserId=");
        sb.append(getAuditUserId());
        sb.append(", createDate=");
        sb.append(getCreateDate());
        sb.append(", modifiedDate=");
        sb.append(getModifiedDate());
        sb.append(", experience=");
        sb.append(getExperience());
        sb.append("}");

        return sb.toString();
    }

    public String toXmlString() {
        StringBundler sb = new StringBundler(22);

        sb.append("<model><model-name>");
        sb.append("org.openwork.portlet.skillmanagement.model.SkillUser");
        sb.append("</model-name>");

        sb.append(
            "<column><column-name>userId</column-name><column-value><![CDATA[");
        sb.append(getUserId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>skillId</column-name><column-value><![CDATA[");
        sb.append(getSkillId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>auditUserId</column-name><column-value><![CDATA[");
        sb.append(getAuditUserId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>createDate</column-name><column-value><![CDATA[");
        sb.append(getCreateDate());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
        sb.append(getModifiedDate());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>experience</column-name><column-value><![CDATA[");
        sb.append(getExperience());
        sb.append("]]></column-value></column>");

        sb.append("</model>");

        return sb.toString();
    }
}
